﻿using FreesenseSubAIS.Core;
using FreesenseSubAIS.NewUI;
using FreesenseSubAIS.SocketModel;
using Microsoft.VisualBasic.ApplicationServices;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace FreesenseSubAIS
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            app = new SplashScreenApplication();
            app.Run(args);

        }
        public static SplashScreenApplication app = null;
    }
    internal sealed class SplashScreenApplication : WindowsFormsApplicationBase
    {
        public SplashScreenApplication()
        {
            //base.IsSingleInstance = true;
            base.EnableVisualStyles = true;
            base.MinimumSplashScreenDisplayTime = 2000;
        }

        protected override void OnCreateMainForm()
        {
            Device.Init();
            SocketInit();
            MainForm = new FormMainNew();
            //((FrmMain)this.MainForm).SetTheme("Office2010Silver");
        }

        private void SocketInit()
        {
            try
            {
                Server.Intrance.Connect(Device.Parameter.SubNetInfo.LocalIP, int.Parse(Device.Parameter.SubNetInfo.SubnetMask));
                initFunction();//初始化从机功能
            }
            catch (Exception ex)
            {

            }
        }
        private void initFunction()
        {
            InspEntity.Intance.SetterInterface(Server.Intrance.SerMgr);
            InspEntity.Intance.GetProjectConfig();
        }
        protected override void OnCreateSplashScreen()
        {
            SplashScreen = new SplashScreenForm();
        }
    }
}
